import turtle


# 我们一起来画风车
def draw_sector(col1, col2, step):
    turtle.color(col1, col1)
    turtle.circle(30, 90 + step)
    turtle.right(90)
    turtle.begin_fill()
    turtle.fd(120)
    turtle.right(90)
    turtle.fd(150)
    turtle.right(135)
    turtle.fd(150 * (1.414) - 30)
    turtle.end_fill()

    turtle.color(col2, col2)
    turtle.begin_fill()
    turtle.right(90)
    turtle.circle(30, 90)
    turtle.right(90)
    turtle.fd(75 * 1.414 - 30)
    turtle.right(90)
    turtle.fd(150 / 1.414)
    turtle.right(135)
    turtle.fd(120)
    turtle.end_fill()

    turtle.right(90)


# 旋转
def rotate():
    turtle.clear()
    turtle.home()
    global step
    turtle.tracer(False)
    turtle.Screen().colormode(255)
    # 画支撑杆
    turtle.pensize(20)
    turtle.penup()
    turtle.goto(0, 32)
    turtle.pendown()
    turtle.right(90)
    turtle.color('lightgray')
    turtle.fd(300)

    turtle.home()
    turtle.pensize(3)
    turtle.Screen().colormode(255)
    draw_sector('green', 'darkgreen', 0 + step)
    draw_sector((26, 188, 156), (22, 160, 133), 0)
    draw_sector((241, 196, 15), (243, 156, 18), 0)
    draw_sector((231, 76, 60), (192, 57, 43), 0)
    step += 1
    turtle.ontimer(rotate, t=1)  # 每隔100毫秒转一次


if __name__ == "__main__":
    # 绘制四个扇形
    turtle.home()
    turtle.pensize(3)
    turtle.Screen().colormode(255)
    draw_sector('green', 'darkgreen', 0)
    draw_sector((26, 188, 156), (22, 160, 133), 0)
    draw_sector((241, 196, 15), (243, 156, 18), 0)
    draw_sector((231, 76, 60), (192, 57, 43), 0)

    # 绘制完成后，让风车转起来
    global step
    step = 0
    rotate()
    turtle.mainloop()
